package com.lwl.controller.scl;


import com.github.pagehelper.PageInfo;
import com.lwl.entity.LayData;
import com.lwl.entity.MyPage;
import com.lwl.entity.scl.TSclVisitRecord;
import com.lwl.entity.scl.VisitRecord;
import com.lwl.service.scl.TSclVisitRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

/**
 * (TSclVisitRecord)表控制层
 *
 * @author makejava
 * @since 2022-11-02 22:56:34
 */
@RestController
@RequestMapping("tSclVisitRecord")
public class TSclVisitRecordController {
    /**
     * 服务对象
     */
    @Autowired
    private TSclVisitRecordService tSclVisitRecordService;

    /*
        检查是否存在这个recordid
     */
    @PostMapping("checkRecordid/{recordid}")
    public LayData checkRecordid(@PathVariable Integer recordid){
        Boolean i = tSclVisitRecordService.checkRecordid(recordid);
        return new LayData(i);
    }

    /*
        添加/修改回访记录
     */
    @PostMapping("addOrUpdateVisitRecord")
    public LayData addOrUpdateVisitRecord(TSclVisitRecord tSclVisitRecord, HttpSession session){
        System.out.println("tSclVisitRecord = " + tSclVisitRecord);
        Boolean i = tSclVisitRecordService.addOrUpdateVisitRecord(tSclVisitRecord,session);
        return new LayData(i);
    }

    /*
        查询所有的回访记录
     */
    @GetMapping("queryAll")
    public LayData queryAll(MyPage myPage, VisitRecord visitRecord){
        PageInfo pageInfo = tSclVisitRecordService.queryAll(myPage,visitRecord);
        return new LayData(pageInfo);
    }
}
